<template>
  <div>
    <navbar select="9" class="navbarBox" ></navbar>

     <div class="formBox">
      <div class="registerTitle">登录</div>
      <el-form :label-position="labelPosition" label-width="85px" :model="formLabelAlign"  >
      <el-form-item label="用户名">
        <el-input v-model="formLabelAlign.phone" placeholder="请输入用户名"></el-input>
      </el-form-item>
      <el-form-item label="密码">
        <el-input type="password" v-model="formLabelAlign.password" placeholder="请输入密码"></el-input>
      </el-form-item>
   
    </el-form>

 <div style="padding-bottom: 200px;">
  <el-button class="submitForm" @click="submitForm()" :style="{background:$store.state.personality}">登录</el-button>
 </div>
     </div>
    <bottom class="bottomBox2"></bottom>
  </div>
</template>
 
<script>
import navbar from "@/components/navbar/navbar.vue";
import bottom from "@/components/bottom/bottom.vue";
import store from "@/store";
export default {
  components: {
    navbar,
    bottom
  },
  data() {
      return {
        labelPosition: 'right',
        formLabelAlign: {
          phone: '',
          password: '',
          country_code:"86"
        },
        avatar:""
        
      };
    },
    methods:{
      //登录
      submitForm() {
        let that = this;
        if(!(that.formLabelAlign.phone && that.formLabelAlign.password)) return this.$message.warning('请将信息填写完整')
            that.apis.login(that.formLabelAlign).then((res) => {
              if(res.code == 0){
                this.$message.success('登录成功')
                this.$router.push({ path: "/"});
                that.avatar = res.data.avatar
                console.log("res.avatar.avater",res.data.avatar)
                localStorage.setItem("avatar",res.data.avatar)
              }else{
                this.$message.error('账号或密码错误')
              }
            });

      },
    }

}
</script>

<style lang="scss" scoped>
.formBox{
  width: 500px;
  margin: 0 auto;
  margin-top: 300px;
}
.registerTitle{
  font-size: 27px;
  text-align: center;
  margin-bottom: 40px;
  padding-left: 70px;
}
.submitForm{
  width:300px;
  border-radius: 50px;
  margin-left: 150px;
  margin-top: 30px;
  color: black;
}
</style>